package com.xc.hotelmgr.webapi.modules.op.controller;

import java.util.Arrays;
import java.util.Map;

import com.xc.hotelmgr.webapi.common.annotation.SysLog;
import com.xc.hotelmgr.webapi.modules.sys.controller.AbstractController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.xc.hotelmgr.webapi.modules.op.entity.RoomPriceEntity;
import com.xc.hotelmgr.webapi.modules.op.service.RoomPriceService;
import com.xc.hotelmgr.webapi.common.utils.PageUtils;
import com.xc.hotelmgr.webapi.common.utils.R;



/**
 * 
 *
 * @author kemmy
 * @email kemmy@gmail.com
 * @date 2020-09-29 14:30:31
 */
@RestController
@RequestMapping("op/roomprice")
public class RoomPriceController extends AbstractController {
    @Autowired
    private RoomPriceService roomPriceService;

    /**
     * 列表
     */
    @SysLog
    @RequestMapping("/list")
    @RequiresPermissions("op:roomprice:list")
    public R list(@RequestParam Map<String, Object> params){
        String dtId = getUserDtId().toString();
        params.put("dtId",dtId);
        PageUtils page = roomPriceService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @SysLog
    @RequestMapping("/info/{id}")
    @RequiresPermissions("op:roomprice:info")
    public R info(@PathVariable("id") Integer id){
		RoomPriceEntity roomPrice = roomPriceService.getById(id);

        return R.ok().put("roomPrice", roomPrice);
    }

    /**
     * 保存
     */
    @SysLog
    @RequestMapping("/save")
    @RequiresPermissions("op:roomprice:save")
    public R save(@RequestBody RoomPriceEntity roomPrice){
        Integer dtId = getUserDtId();
        roomPrice.setDtId(dtId);
		roomPriceService.save(roomPrice);

        return R.ok();
    }

    /**
     * 修改
     */
    @SysLog
    @RequestMapping("/update")
    @RequiresPermissions("op:roomprice:update")
    public R update(@RequestBody RoomPriceEntity roomPrice){
		roomPriceService.updateById(roomPrice);

        return R.ok();
    }

    /**
     * 删除
     */
    @SysLog
    @RequestMapping("/delete")
    @RequiresPermissions("op:roomprice:delete")
    public R delete(@RequestBody Integer[] ids){
		roomPriceService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
